package com.kaifamiao.jdbc.core;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

// Oracle 10g 开始建议用 `oracle.jdbc.OracleDriver` 取代 `oracle.jdbc.driver.OracleDriver`
// 但是，为了照顾老年人的感受，我们用 `oracle.jdbc.driver.OracleDriver` 以兼容他们的顽固不化
public class DriverOracleTest {

    public static void main(String[] args) throws SQLException {

        String url = "jdbc:oracle:thin:@localhost:1521:kaifamiao";
        String username = "kaifamiao";
        String password = "kaifamiao";

        // 创建驱动类的实例
        Driver driver = new oracle.jdbc.driver.OracleDriver();
        System.out.println( driver );

        // 注册驱动
        DriverManager.registerDriver( driver );

        // 获得数据库连接
        Connection conn = DriverManager.getConnection( url, username, password );
        System.out.println( conn );

        // 释放资源
        conn.close();
    }

}
